package cn.itsource.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.itsource.domain.Driver;
import cn.itsource.domain.DriverSummary;
import cn.itsource.mapper.DriverMapper;
import cn.itsource.mapper.DriverSummaryMapper;
import cn.itsource.pojo.vo.AppDriverAuthMaterialVo;
import cn.itsource.service.IDriverSummaryService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 司机结算对象 服务实现类
 * </p>
 *
 * @author zls
 * @since 2024-07-02
 */
@Service
public class DriverSummaryServiceImpl extends ServiceImpl<DriverSummaryMapper, DriverSummary> implements IDriverSummaryService {

    @Autowired
    private DriverMapper driverMapper;
    @Override
    public AppDriverAuthMaterialVo getDriverMaterial() {
        String openId = (String) StpUtil.getExtra("openId");
        Driver driver = driverMapper.selectOne(new LambdaQueryWrapper<Driver>().eq(Driver::getOpenId, openId));
        DriverSummary driverSummary = super.getById(driver.getId());
        AppDriverAuthMaterialVo appDriverAuthMaterialVo = new AppDriverAuthMaterialVo(driverSummary.getDriveDuration(),driverSummary.getTodayIncome(),driverSummary.getTodayTradeOrders());
        return appDriverAuthMaterialVo;
    }
}
